package com.itheima.jobs;

import com.itheima.constant.RedisConstant;
import com.itheima.utils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.JedisPool;

import java.util.Set;

/**
 * @Author: bowen
 * @Date: 2019/6/25 20:23
 * @Description:
 */
public class ClearRubish {
    @Autowired
    JedisPool jedisPool;

    public void clearImg(){

        Set<String> sdiff = jedisPool.getResource().sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);
        for (String s : sdiff) {
            System.out.println("清理图片："+s);
            QiniuUtils.deleteFileFromQiniu(s);
            jedisPool.getResource().srem(RedisConstant.SETMEAL_PIC_RESOURCES,s);
        }

    }
}
